import AsyncStorage from '@react-native-async-storage/async-storage';
import { persistReducer } from 'redux-persist';
import { configureStore } from '@reduxjs/toolkit';
import { setupListeners } from '@reduxjs/toolkit/query';

// 引入状态改变策略
import userReducer from './user';

// 状态持久化
// 配置
const persistConfig = {
  key: "root",
  storage: AsyncStorage,
}
const userPersistReducer = persistReducer(persistConfig,userReducer);


// 导出reducer策略的action
export * from './user';

// 根据configureStore创建store
export const store = configureStore({
  reducer: {
    user: userPersistReducer,
  },
  middleware: (getDefaultMiddleware) => getDefaultMiddleware({
    //关闭redux序列化检测
    serializableCheck:false
  }),
})

setupListeners(store.dispatch)